#include "message.h"
#include "ui_message.h"

void message::set_Message(QString text)
{

    ui->label->setText(text);
    QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity");
    animation->setDuration(1500);
    animation->setStartValue(1);
    animation->setEndValue(0);
    animation->setEasingCurve(QEasingCurve::Linear);//渐变时间曲线
    animation->start();
    connect(animation, &QPropertyAnimation::finished, this, [this]{close(); });
}

void message::iniUI()
{
    QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
    shadow_effect->setOffset(0, 0);              //阴影的偏移量
    shadow_effect->setColor(QColor(68, 43, 43)); //阴影的颜色
    shadow_effect->setBlurRadius(20);             // 阴影圆角的大小
    ui->label->setGraphicsEffect(shadow_effect); //给那个控件设置阴影，这里需要注意的是所有此控件的子控件，也都继承这个阴影。
    setStyleSheet("#label{border: 1.5px solid #ccc;border-radius: 4px;background-color:#E066FF;font:25px;color:#fff;font-family: 'Microsoft soft';}");
    //设置窗体透明
    this->setAttribute(Qt::WA_TranslucentBackground, true);
    //设置无边框
    this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
}

message::message(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::message)
{

    ui->setupUi(this);
    iniUI();


}

message::~message()
{
    delete ui;
}
